#version 430 
layout(location= 100)uniform vec4 uColor;
layout(location= 200) uniform vec3 eyePostion;
layout(location= 300) uniform sampler2D tex;

out vec4 outColor;

vec3 lightDir =  vec3(0, -2, -1);

in vec3 vpos;
in vec3 vnormal;
in vec2 vtexCood;


void main()
{
	vec3 halfVec = normalize(eyePostion - vpos) - normalize(lightDir);
	halfVec =normalize(halfVec);
	vec3 normal = normalize(vnormal);
	float r = max(dot(halfVec, normal), 0);
	float diffuse =  (dot(normal, -lightDir)*0.5 + 0.5)  *0.2;
	vec4 texColor = texture(tex, vtexCood);
	outColor.rgb = uColor.rgb*texColor.rgb*
	           (0.4 + diffuse) + vec3(1.0) *(r *0.1 + pow(r, 50)*0.1 );
	outColor.a = texColor.a;
}